package com.qqt.csr.message.event.intrasite.workorder;

import com.qqt.csr.message.event.EventPublisherStrategy;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * @Author: yang hao
 * @Date: 2024/12/18 9:07
 * @Description: 工单事件发布策略
 **/
@Component
public class WorkOrderEventPublisherStrategy implements EventPublisherStrategy {

    /**
     * 发布事件
     * @param eventPublisher {@link ApplicationEventPublisher} 事件发布者
     * @param source         {@link Object} 事件源
     */
    @Override
    public void publish(ApplicationEventPublisher eventPublisher, Object source) {
        if (isSupport(source)) {
            eventPublisher.publishEvent(new WorkOrderIntraSiteMessageEvent((WorkOrderEventSource)source));
        }
    }

    /**
     * 获取事件源类型
     * @return {@link Class} 事件源类型
     */
    @Override
    public Class<?> getSourceType() {
        return WorkOrderEventSource.class;
    }

}
